package CloudDataBase.Project3.Group3.s12cs342;

import java.util.ArrayList;

public class questionContainer {
	private String type, question, correctAnswer;
	
	private double pointsWorth;
	
	@SuppressWarnings("rawtypes") private ArrayList answers;
	
	private boolean TFAnswer;
	
	/**
	 * Constructor to create any of the current question styles
	 * 
	 * @param type - 0, 1, or 2 for Multiple Choice, True or False, or Short answer respectively
	 * @param question - The question to be asked
	 * @param answers - Possible answers (Only needed for Multiple Choice, null in other styles)
	 * @param correctAnswer - The correct answer to the question
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public questionContainer(int type, String question, ArrayList answers, String correctAnswer, double pointsWorth){
		
		switch (type){
		case 0: this.type = "Multiple Choice";
				this.question = question;
				this.answers = answers;
				this.correctAnswer = correctAnswer;
				this.setPointsWorth(pointsWorth);
				break;
		case 1: this.type = "True or False";
				this.question = question;
				this.answers.add(true);
				this.answers.add(false);
				if (correctAnswer.equals("True")){
					this.TFAnswer = true;
				}else{
					this.TFAnswer = false;
				}
				this.setPointsWorth(pointsWorth);
				break;
		case 2: this.type = "Short Answer";
				this.question = question;
				this.answers = null;
				this.correctAnswer = correctAnswer;
				this.setPointsWorth(pointsWorth);
				break;
		default:System.err.println("Bad question type: " + type + ". Only 0, 1, and 2 are currently useable");
				break;
			
		}
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getQuestion() {
		return question;
	}

	public void setQuestion(String question) {
		this.question = question;
	}

	public String getCorrectAnswer() {
		return correctAnswer;
	}

	public void setCorrectAnswer(String correctAnswer) {
		this.correctAnswer = correctAnswer;
	}

	@SuppressWarnings("rawtypes")
	public ArrayList getAnswers() {
		return answers;
	}

	@SuppressWarnings("rawtypes")
	public void setAnswers(ArrayList answers) {
		this.answers = answers;
	}

	public boolean isTFAnswer() {
		return TFAnswer;
	}

	public void setTFAnswer(boolean tFAnswer) {
		TFAnswer = tFAnswer;
	}

	public double getPointsWorth() {
		return pointsWorth;
	}

	public void setPointsWorth(double pointsWorth) {
		this.pointsWorth = pointsWorth;
	}
	
	/**
	 * A method to get the int representation of a question type.
	 * 
	 * If -1 is returned the String do not match a question type.
	 * 
	 * @param type - The String type of the question
	 * @return - The integer that is related to that type
	 */
	public int getQuestionIntType(String type){
		if (type.equals("Multiple Choice")){
			return 0;
		}else if (type.equals("True or False")){
			return 1;
		}else if (type.equals("Short Answer")){
			return 2;
		}else{
			return -1;
		}
	}
	
	/**
	 * A method to get the related String Type from an int.
	 * 
	 * @param type - int of the type
	 * @return - the string name of the related Type or an error message
	 */
	public String getQuestionStringType(int type){
		switch(type){
		case 0: return "Multiple Choice";
		case 1: return "True or False";
		case 2: return "Short Answer";
		default: return "Currently only 0 through 2 represent question types";
		}
	}
}
